//
//  DRInviteUserCell.m
//  DoctorRen
//
//  Created by 范伟健 on 2018/12/17.
//

#import "DRInviteUserCell.h"
#import <Masonry/Masonry.h>
#import "DRFoodPairingModel.h"

@interface DRInviteUserCell ()

@property (nonatomic, strong) UIImageView *userAvatar;

@property (nonatomic, strong) UIButton *closeButton;

@end

@implementation DRInviteUserCell


-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupSubViews];
        [self.closeButton addTarget:self action:@selector(clickCloseButton) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}

-(void)setUser:(DRFriendModel *)user{
    [self.userAvatar setImageWithURLString:user.path];
}

-(void) setupSubViews{
    [self.userAvatar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
    
    [self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.mas_equalTo(0);
        make.height.with.mas_equalTo(16);
    }];
}

-(void) clickCloseButton{
    if (self.tapCloseButton) {
        self.tapCloseButton();
    }
}

-(UIImageView *)userAvatar{
    if (!_userAvatar) {
        _userAvatar = [UIImageView new];
        _userAvatar.layer.cornerRadius = 18;
        _userAvatar.layer.masksToBounds = YES;
        [self addSubview:_userAvatar];
    }
    return _userAvatar;
}

-(UIButton *)closeButton{
    if (!_closeButton) {
        _closeButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_closeButton setImage:[UIImage imageNamed:@"头像_删除"] forState:(UIControlStateNormal)];
        [self addSubview:_closeButton];
    }
    return _closeButton;
}

@end
